package p270jp.pxv.android.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
import java.util.Objects;
import p014ae.View$OnClickListenerC0050b;
import p045be.IllustGridRecyclerAdapter;
import p134ei.AnalyticsAction;
import p134ei.PixivAnalytics;
import p140eo.C2973b;
import p165fo.C3114c;
import p270jp.pxv.android.R;
import p270jp.pxv.android.event.ShowRequiredPremiumDialogEvent;
import p270jp.pxv.android.legacy.constant.SearchSort;
import p270jp.pxv.android.legacy.model.PixivIllust;
import p270jp.pxv.android.model.PopularPreviewItem;
import p307l9.EdgeTreatment;
import p368ng.AbstractC5243x0;
import p451qm.GridItemDecoration;

/* renamed from: jp.pxv.android.viewholder.PopularPreviewItemViewHolder */
/* loaded from: classes2.dex */
public class PopularPreviewItemViewHolder extends BaseViewHolder {
    private static final int COLUMN_NUM;
    private static final int ROW_NUM;
    private IllustGridRecyclerAdapter adapter;
    private View clickableArea;
    private final PixivAnalytics pixivAnalytics;
    private ProgressBar progressBar;
    private RecyclerView recyclerView;

    public PopularPreviewItemViewHolder(View view) {
        super(view);
        this.recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
        this.progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
        this.clickableArea = view.findViewById(R.id.clickable_area);
        this.pixivAnalytics = ((AbstractC5243x0) C2973b.m6512b(view.getContext(), AbstractC5243x0.class)).mo3365R();
    }

    /* renamed from: a */
    public static /* synthetic */ void m4403a(PopularPreviewItem popularPreviewItem, View view) {
        lambda$bind$0(popularPreviewItem, view);
    }

    public static int getLayoutRes() {
        return R.layout.view_popular_preview_item;
    }

    public static /* synthetic */ void lambda$bind$0(PopularPreviewItem popularPreviewItem, View view) {
        C3114c.m6284b().m6280f(new ShowRequiredPremiumDialogEvent(popularPreviewItem.getSearchSort()));
    }

    @Override // p270jp.pxv.android.viewholder.BaseViewHolder
    public void bind(Object obj) {
        super.bind(obj);
        PopularPreviewItem popularPreviewItem = (PopularPreviewItem) obj;
        if (popularPreviewItem.getSearchSort() == SearchSort.ASC) {
            this.pixivAnalytics.m6528b(7, AnalyticsAction.PREMIUM_POPULAR_PREVIEW_VIEW_AT_SEARCH_RESULT_OLD);
        } else if (popularPreviewItem.getSearchSort() == SearchSort.DESC) {
            this.pixivAnalytics.m6528b(7, AnalyticsAction.PREMIUM_POPULAR_PREVIEW_VIEW_AT_SEARCH_RESULT_NEW);
        }
        this.clickableArea.setOnClickListener(new View$OnClickListenerC0050b(popularPreviewItem, 25));
        List<PixivIllust> previewImages = popularPreviewItem.getPreviewImages();
        if (previewImages != null && this.adapter.mo1393c() == 0) {
            this.progressBar.setVisibility(8);
            IllustGridRecyclerAdapter tVar = this.adapter;
            List<PixivIllust> subList = previewImages.subList(0, Math.min(previewImages.size(), 6));
            Objects.requireNonNull(tVar);
            EdgeTreatment.m3909i(subList);
            tVar.m10337r(subList, subList, null);
        }
    }

    @Override // p270jp.pxv.android.viewholder.BaseViewHolder
    public void onCreateView(ViewGroup viewGroup) {
        super.onCreateView(viewGroup);
        IllustGridRecyclerAdapter tVar = new IllustGridRecyclerAdapter(this.itemView.getContext(), 2, 3);
        this.adapter = tVar;
        this.recyclerView.setAdapter(tVar);
        this.recyclerView.m10871g(new GridItemDecoration(this.itemView.getContext().getResources().getDimensionPixelSize(R.dimen.illust_item_divider_size), 3, 0));
        this.recyclerView.setLayoutManager(new GridLayoutManager(this.itemView.getContext(), 3));
    }
}
